package cn.xzqwjw.taskmanager.common.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 自定义请求拦截器
 *
 * @author rush
 */
@Slf4j
public class WebInterceptor implements HandlerInterceptor {

  /**
   * 请求之前进行拦截
   */
  @Override
  public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
    // SysAdmin admin = CommonUtil.checkLoggedIn(request.getSession());
    // if (Objects.isNull(admin)) {
    // log.error("拦截到没有权限的登录请求，url是：{}", request.getRequestURI().toLowerCase());
    // 未登录，返回登录页面
    // request.setAttribute("ErrorMessage", "没有权限，请登录！");
    // request.getRequestDispatcher("/cms/login").forward(request, response);
    //    response.sendRedirect("/cms/login");
    //    return false;
    //  } else
    //  {
    //    return true;
    //  }
    return true;
  }

}
